<template>
    <div>
        <div class="cell-tip" :style="{ marginBottom: bottom }" v-if="!showMore">
            <el-icon size="15px" color="#4B93FA"><WarningFilled /></el-icon>
            <span v-if="tip">{{ tip }}</span>
            <slot name="tip" v-else></slot>
        </div>
        <div class="cell-info" :style="{ marginBottom: bottom }" v-else>
            <p v-for="(item, index) in datas" :key="index" @click.stop="onClick(item, index)">
                {{ item }}
            </p>
        </div>
    </div>
</template>

<script setup>
import { ref } from "vue"
import { WarningFilled } from "@element-plus/icons-vue"

/**
 * 警告/提示框容器
 * @property {String} tip 提示文本
 * @property {Boolean} showMore 是否显示多行
 * @property {Array} datas 多行数据
 */
const props = defineProps({
    bottom: {
        type: String,
        default: "16px",
    },
    tip: {
        type: String,
        default: "",
    },
    showMore: {
        type: Boolean,
        default: false,
    },
    datas: {
        type: Array,
        default() {
            return []
        },
    },
})

const emits = defineEmits(["click"])
const onClick = (item, index) => {
    emits("click", item, index)
}
</script>

<style lang="less" scoped>
.cell-tip {
    font-size: @font-size-md;
    line-height: 20px;
    display: flex;
    align-items: center;
    background: #eaf5ff;
    padding: @padding-sm @padding-md;
    border-radius: 2px;
    border: 1px solid #86b7fc;
    color: @gray-8;
    .el-icon {
        margin-right: @margin-xs;
    }
}
.cell-info {
    background-color: #eaf5ff;
    border: 1px solid #86b7fc;
    position: relative;
    padding: @padding-sm @padding-mdl;
    border-radius: 2px;
    font-size: @font-size-md;
    word-wrap: break-word;
    color: #323233;
    p {
        margin-bottom: @margin-base;
        &:last-child {
            margin-bottom: 0;
        }
    }
    i {
        color: @themes;
        margin-right: @margin-xs;
    }
}
</style>
